using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DTO;
using BUS;
using DAL;
using Utility;
public partial class admin_A_Hinhthucthanhtoan_insert : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btcapnhat_Click(object sender, EventArgs e)
    {
        //try
        //{

        HinhThucThanhToan_DTO httt = new HinhThucThanhToan_DTO();
        httt.TenHinhThucThanhToan = txttenht.Text;
        if (txttenht.Text == "")
        {
            ten.Visible = true;
            return;
        }
        else
        {
            ten.Visible = false;
        }

        httt.MoTa = txtmota.Text;
        if (txtmota.Text == "")
        {
            mota.Visible = true;
            return;
        }
        else
        {
            mota.Visible = false;
        }
        if (fu_hinh.HasFile)
        {
            string filename = DateTime.Now.Ticks.ToString() + "_" + fu_hinh.FileName;
            fu_hinh.SaveAs(Server.MapPath("~/Photos/" + filename));

            System.Drawing.Image img = System.Drawing.Image.FromFile(
                Server.MapPath("~/Photos/" + filename));

            ImageUtility.MakeThumbnailPhoto(
                img, 100, 100, Server.MapPath("~/Photos/Thumb/"), filename);

            httt.HinhAnh = filename;
            hinh.Visible = false;

        }
        else
        {
            hinh.Visible = true;
            return;
            //httt.HinhAnh = "no_images.jpg";
        }
        
        //httt.HinhAnh = hinh
        HinhThucThanhToan_BUS.Insert(httt);
        hinh.Visible = false;
        ten.Visible = false;
         mota.Visible = false;
        
        Response.Redirect("~/admin/A_hinhthucthanhtoan.aspx");

        //}
        //catch
        //{
        //    Response.Redirect("~/admin/LoaiHang.aspx");
        //}
        //Response.Redirect(Request.RawUrl);
    }
}
